#!/usr/bin/perl
#change_bond_stat.cgi

require './network-lib.pl';

if(&check_bond_stat())
{
	`/etc/sysconfig/network-scripts/bond_cfg stop`; 
}
else
{
	`/etc/sysconfig/network-scripts/bond_cfg start`;
}
&redirect("conf_bond.cgi");

sub read_file_byline()
{
        my ($ptf, $filename);

        $filename = @_[0];
        $ptf = @_[1];

        open(RFILE, $filename);
        @$ptf = <RFILE>;
        close(RFILE);
}
sub check_bond_stat()
{
	$bonding = "off";
	`/sbin/lsmod >/home/saintxy/bond`;

 	local @lref;
 	&read_file_byline("/home/saintxy/bond",\@lref);
 	foreach $line (@lref)
 	{
 		if($line=~/bonding/)
 		{
 			$bonding = "on";
 			last;
 		}
 	}
 	`rm -f /home/saintxy/bond`;
 	if($bonding eq "on")
 	{
		return 1;
	}
	else
	{
		return 0;
	}
}